Skip to content

Conversation

@jiashengguo
Copy link
Member

@jiashengguo jiashengguo commented Jan 9, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Clearer error messages when schema or generator blocks are missing.
    • More reliable device identification to improve telemetry stability.
  • Enhancements

    • Improved datasource URL parsing with better guidance for newer Prisma versions and unsupported setups.
  • Chores

    • Package version bumped to 0.2.3 and added a UUID generation dependency.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 9, 2026 02:27
@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Updates package version to 0.2.3 and adds the uuid dependency; replaces crypto random UUID usage with uuid.v4 in machine-id utils; telemetry now derives a stable device ID via UUIDv5 using a fixed namespace; refines Prisma datasource parsing and several error messages.

Changes

Cohort / File(s) Summary
Package Configuration
package.json
Version bumped from 0.2.1 to 0.2.3; adds dependency uuid ^13.0.0; minor JSON formatting adjustment.
Telemetry
src/telemetry.ts
Replaces direct machine-id usage with this.getDeviceId() and imports v5 as uuidv5 from uuid; computes hostId via UUIDv5 using fixed namespace.
Machine ID utilities
src/utils/machine-id-utils.ts
Replaces randomUUID fallback with uuid() (v4); tighter typing for exposed id (no undefined); updated fallback/error paths to return uuid().
CLI entry / errors
src/index.ts
Removes "Error: " prefix from the ZModel schema file-not-found message (minor formatting change).
ZModel / Prisma parsing
src/zmodel-parser.ts
Reworks datasource URL extraction and evaluation (single regex capture, env helper that throws on missing vars, Function-based eval); simplifies loadPrismaConfig evaluation path; updates generator-not-found error text to mention ZenStack V3 non-support.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through code with a tiny cheer,
UUIDs lined up, both far and near,
v4 for a fallback, v5 to bind,
Parsers tuned and messages refined.
A joyful nibble — new IDs assigned! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: shows v3 not supported message' is only partially related to the changeset. While one aspect involves adding a V3 unsupported message in zmodel-parser.ts, the PR makes broader changes across package.json, src/index.ts, src/telemetry.ts, and src/utils/machine-id-utils.ts including UUID dependency addition, error message refinement, and UUID generation updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1e2afd5 and 13b76e0.

📒 Files selected for processing (2)
  • package.json
  • src/zmodel-parser.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/zmodel-parser.ts
  • package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Dependabot
  • GitHub Check: Dependabot
  • GitHub Check: build-test (20.x)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the error messaging for unsupported ZenStack V3 schemas and migrates from Node.js built-in UUID functions to the external uuid package. The changes also improve device ID generation for telemetry by applying UUIDv5 hashing.

Key Changes:

  • Added informative error message when no generator block is found, indicating V3 is not supported
  • Migrated from node:crypto randomUUID to uuid package v4 and v5 functions
  • Implemented UUIDv5-based device ID hashing in telemetry for better privacy

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/zmodel-parser.ts Enhanced error message to inform users that ZenStack V3 is not supported
src/utils/machine-id-utils.ts Replaced Node.js randomUUID with uuid package v4, changed expose() return type
src/telemetry.ts Added getDeviceId() method using UUIDv5 to hash machine IDs for privacy
src/index.ts Removed "Error:" prefix from error message for consistency
package.json Added uuid ^13.0.0 dependency and bumped version to 0.2.2
pnpm-lock.yaml Updated lockfile with uuid 13.0.0 package resolution
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

function expose(result: string): string | undefined {
function expose(result: string): string {
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type was changed to string, but the function can still return undefined due to optional chaining operators in the switch cases. For example, on line 41-42, the expression could return undefined if the split or replace operations don't find matches. This will cause a type mismatch when calling hash(id) on line 71, as hash() expects a string parameter.

Copilot uses AI. Check for mistakes.
if (!generatorMatch) {
throw new CliError('No generator block found in zmodel schema')
throw new CliError(
'No generator block found in zmodel schema.\nZenStack V3 is not supported, V3 will have built-in proxy support soon.'
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message states "V3 will have built-in proxy support soon" which uses future tense but may be confusing to users. Consider clarifying whether this message is specifically for users currently on V2 trying to use V3, or revising to make the message clearer about the current state and expected timeline.

Suggested change
'No generator block found in zmodel schema.\nZenStack V3 is not supported, V3 will have built-in proxy support soon.'
'No generator block found in zmodel schema.\nZenStack V3 schemas are not supported by this CLI yet. Built-in proxy support for V3 is planned but not currently available.'

Copilot uses AI. Check for mistakes.

private getDeviceId() {
const hostId = getMachineId()
// namespace UUID for generating UUIDv5 from DNS 'zenstack.dev'
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states this is a "namespace UUID for generating UUIDv5 from DNS 'zenstack.dev'", but the hardcoded UUID should be verified. The standard DNS namespace UUID is '6ba7b810-9dad-11d1-80b4-00c04fd430c8'. If '133cac15-3efb-50fa-b5fc-4b90e441e563' is a custom namespace derived from 'zenstack.dev', the comment should clarify this to avoid confusion.

Suggested change
// namespace UUID for generating UUIDv5 from DNS 'zenstack.dev'
// Custom UUIDv5 namespace used for ZenStack telemetry (derived from DNS name 'zenstack.dev')

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/utils/machine-id-utils.ts (1)

35-62: Type safety issue: expose() can return undefined despite return type.

The expose() function's return type was changed from string | undefined to string, but the implementation still uses optional chaining operators (?.) that can return undefined. For example:

result.split('IOPlatformUUID')[1]?.split('\n')[0]?.replace(...).toLowerCase()

If split('IOPlatformUUID')[1] is undefined, the entire chain returns undefined, violating the return type and potentially causing hash(undefined) to be called at line 71.

🔧 Proposed fix

Either revert the return type to include undefined:

-function expose(result: string): string {
+function expose(result: string): string | undefined {

Or add a fallback to ensure a string is always returned:

 function expose(result: string): string {
   switch (platform) {
     case 'darwin':
-      return result
+      return (result
         .split('IOPlatformUUID')[1]
         ?.split('\n')[0]
         ?.replace(/=|\s+|"/gi, '')
-        .toLowerCase()
+        .toLowerCase()) ?? ''
     // ... similar changes for other cases

Then update getMachineId() to handle empty strings:

   try {
     const value = execSync(guid[platform as keyof typeof guid])
     const id = expose(value.toString())
-    return hash(id)
+    return id ? hash(id) : uuid()
   } catch {
     return uuid()
   }
🤖 Fix all issues with AI agents
In @src/telemetry.ts:
- Around line 44-48: The getDeviceId() function currently uses uuidv5(hostId,
'133cac15-3efb-50fa-b5fc-4b90e441e563') but the hard-coded UUID is not the RFC
4122 DNS namespace; either replace that second argument with the standard DNS
namespace UUID '6ba7b810-9dad-11d1-80b4-00c04fd430c8' if you intended to derive
a DNS-based UUID, or keep the custom UUID but update the comment to explicitly
state it is a deliberately chosen custom namespace for privacy/anonymization
(mentioning getDeviceId(), hostId, and uuidv5 to locate the change).
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 004579b and 1e2afd5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • package.json
  • src/index.ts
  • src/telemetry.ts
  • src/utils/machine-id-utils.ts
  • src/zmodel-parser.ts
🧰 Additional context used
🧬 Code graph analysis (3)
src/zmodel-parser.ts (1)
src/cli-error.ts (1)
  • CliError (4-4)
src/utils/machine-id-utils.ts (1)
src/utils/exec-utils.ts (1)
  • execSync (6-15)
src/telemetry.ts (1)
src/utils/machine-id-utils.ts (1)
  • getMachineId (64-75)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Dependabot
  • GitHub Check: Agent
🔇 Additional comments (5)
src/zmodel-parser.ts (1)

160-162: LGTM! Clear error message for V3 limitation.

The enhanced error message clearly communicates that ZenStack V3 is not currently supported and provides context about future built-in proxy support. This aligns well with the PR objective.

src/index.ts (1)

34-34: LGTM! Cleaner error message format.

Removing the "Error: " prefix reduces redundancy since console.error already indicates an error condition.

src/telemetry.ts (1)

22-22: LGTM! Enhanced device ID anonymization.

The new getDeviceId() method adds an additional layer of anonymization by computing a UUIDv5 from the machine ID. This provides better privacy protection while maintaining deterministic device identification across sessions.

Also applies to: 44-48

src/utils/machine-id-utils.ts (1)

4-5: LGTM! Consistent UUID library usage.

The migration from crypto.randomUUID() to uuid.v4() provides consistency with the UUID library now used across the codebase (including telemetry). Both generate UUID v4 values equivalently.

Also applies to: 66-66, 73-73

package.json (1)

37-37: No action needed — [email protected] exists and is the latest stable version.

The version specified in the dependency is correct and available on npm.

Likely an incorrect or invalid review comment.

Comment on lines +44 to +48
private getDeviceId() {
const hostId = getMachineId()
// namespace UUID for generating UUIDv5 from DNS 'zenstack.dev'
return uuidv5(hostId, '133cac15-3efb-50fa-b5fc-4b90e441e563')
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

RFC 4122 DNS namespace UUID v5 standard

💡 Result:

Short answer:

  • RFC 4122 (UUIDs) defines name-based UUIDv5 as SHA-1(name + namespace) with bits set for version=5 and the RFC 4122 variant. [1]
  • The standard DNS namespace UUID (used as the namespace input when generating UUIDv5 for domain names) is: 6ba7b810-9dad-11d1-80b4-00c04fd430c8. [2]
  • Note: RFC 4122 was obsoleted by RFC 9562 (May 2024); RFC 9562 preserves these namespace IDs and describes current UUID rules and namespace allocation. [2][1]

Sources:
[1] RFC 4122 (A Universally Unique IDentifier (UUID) URN Namespace).
[2] RFC 9562 (Universally Unique IDentifiers (UUIDs)) — Table 3 (Namespace IDs) and namespace allocation.


🏁 Script executed:

# Search for any documentation or comments about the custom namespace UUID
rg "133cac15-3efb-50fa-b5fc-4b90e441e563" --type ts --type js

# Also check for any comments or documentation about zenstack namespace
rg -i "zenstack.*namespace\|namespace.*zenstack" --type ts --type js -A 2 -B 2

Repository: zenstackhq/proxy

Length of output: 142


Clarify the namespace UUID usage.

The namespace UUID '133cac15-3efb-50fa-b5fc-4b90e441e563' doesn't match the standard DNS namespace UUID defined in RFC 4122 (6ba7b810-9dad-11d1-80b4-00c04fd430c8). The comment stating "namespace UUID for generating UUIDv5 from DNS 'zenstack.dev'" is misleading—if this is intentionally a custom namespace for privacy/anonymization, update the comment to reflect that. If it should use the RFC 4122 standard DNS namespace, correct the UUID.

🤖 Prompt for AI Agents
In @src/telemetry.ts around lines 44 - 48, The getDeviceId() function currently
uses uuidv5(hostId, '133cac15-3efb-50fa-b5fc-4b90e441e563') but the hard-coded
UUID is not the RFC 4122 DNS namespace; either replace that second argument with
the standard DNS namespace UUID '6ba7b810-9dad-11d1-80b4-00c04fd430c8' if you
intended to derive a DNS-based UUID, or keep the custom UUID but update the
comment to explicitly state it is a deliberately chosen custom namespace for
privacy/anonymization (mentioning getDeviceId(), hostId, and uuidv5 to locate
the change).

@jiashengguo jiashengguo merged commit def99f3 into main Jan 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants